/**
 * <copyright>
 * </copyright>
 *

 */
package hu.bme.mit.androtext.nav.androNav.impl;

import hu.bme.mit.androtext.nav.androNav.AndroNavPackage;
import hu.bme.mit.androtext.nav.androNav.AndroNavRoot;
import hu.bme.mit.androtext.nav.androNav.EventLibrary;
import hu.bme.mit.androtext.nav.androNav.ImageLibrary;
import hu.bme.mit.androtext.nav.androNav.Navigation;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Root</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link hu.bme.mit.androtext.nav.androNav.impl.AndroNavRootImpl#getName <em>Name</em>}</li>
 *   <li>{@link hu.bme.mit.androtext.nav.androNav.impl.AndroNavRootImpl#getNavigation <em>Navigation</em>}</li>
 *   <li>{@link hu.bme.mit.androtext.nav.androNav.impl.AndroNavRootImpl#getImageLibrary <em>Image Library</em>}</li>
 *   <li>{@link hu.bme.mit.androtext.nav.androNav.impl.AndroNavRootImpl#getEventLibrary <em>Event Library</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AndroNavRootImpl extends MinimalEObjectImpl.Container implements AndroNavRoot
{
  /**
   * The default value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected static final String NAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getName()
   * @generated
   * @ordered
   */
  protected String name = NAME_EDEFAULT;

  /**
   * The cached value of the '{@link #getNavigation() <em>Navigation</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getNavigation()
   * @generated
   * @ordered
   */
  protected Navigation navigation;

  /**
   * The cached value of the '{@link #getImageLibrary() <em>Image Library</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getImageLibrary()
   * @generated
   * @ordered
   */
  protected ImageLibrary imageLibrary;

  /**
   * The cached value of the '{@link #getEventLibrary() <em>Event Library</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getEventLibrary()
   * @generated
   * @ordered
   */
  protected EventLibrary eventLibrary;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected AndroNavRootImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return AndroNavPackage.Literals.ANDRO_NAV_ROOT;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getName()
  {
    return name;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setName(String newName)
  {
    String oldName = name;
    name = newName;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AndroNavPackage.ANDRO_NAV_ROOT__NAME, oldName, name));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Navigation getNavigation()
  {
    return navigation;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetNavigation(Navigation newNavigation, NotificationChain msgs)
  {
    Navigation oldNavigation = navigation;
    navigation = newNavigation;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AndroNavPackage.ANDRO_NAV_ROOT__NAVIGATION, oldNavigation, newNavigation);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setNavigation(Navigation newNavigation)
  {
    if (newNavigation != navigation)
    {
      NotificationChain msgs = null;
      if (navigation != null)
        msgs = ((InternalEObject)navigation).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AndroNavPackage.ANDRO_NAV_ROOT__NAVIGATION, null, msgs);
      if (newNavigation != null)
        msgs = ((InternalEObject)newNavigation).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AndroNavPackage.ANDRO_NAV_ROOT__NAVIGATION, null, msgs);
      msgs = basicSetNavigation(newNavigation, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AndroNavPackage.ANDRO_NAV_ROOT__NAVIGATION, newNavigation, newNavigation));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public ImageLibrary getImageLibrary()
  {
    return imageLibrary;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetImageLibrary(ImageLibrary newImageLibrary, NotificationChain msgs)
  {
    ImageLibrary oldImageLibrary = imageLibrary;
    imageLibrary = newImageLibrary;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AndroNavPackage.ANDRO_NAV_ROOT__IMAGE_LIBRARY, oldImageLibrary, newImageLibrary);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setImageLibrary(ImageLibrary newImageLibrary)
  {
    if (newImageLibrary != imageLibrary)
    {
      NotificationChain msgs = null;
      if (imageLibrary != null)
        msgs = ((InternalEObject)imageLibrary).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AndroNavPackage.ANDRO_NAV_ROOT__IMAGE_LIBRARY, null, msgs);
      if (newImageLibrary != null)
        msgs = ((InternalEObject)newImageLibrary).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AndroNavPackage.ANDRO_NAV_ROOT__IMAGE_LIBRARY, null, msgs);
      msgs = basicSetImageLibrary(newImageLibrary, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AndroNavPackage.ANDRO_NAV_ROOT__IMAGE_LIBRARY, newImageLibrary, newImageLibrary));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EventLibrary getEventLibrary()
  {
    return eventLibrary;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetEventLibrary(EventLibrary newEventLibrary, NotificationChain msgs)
  {
    EventLibrary oldEventLibrary = eventLibrary;
    eventLibrary = newEventLibrary;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, AndroNavPackage.ANDRO_NAV_ROOT__EVENT_LIBRARY, oldEventLibrary, newEventLibrary);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setEventLibrary(EventLibrary newEventLibrary)
  {
    if (newEventLibrary != eventLibrary)
    {
      NotificationChain msgs = null;
      if (eventLibrary != null)
        msgs = ((InternalEObject)eventLibrary).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - AndroNavPackage.ANDRO_NAV_ROOT__EVENT_LIBRARY, null, msgs);
      if (newEventLibrary != null)
        msgs = ((InternalEObject)newEventLibrary).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - AndroNavPackage.ANDRO_NAV_ROOT__EVENT_LIBRARY, null, msgs);
      msgs = basicSetEventLibrary(newEventLibrary, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, AndroNavPackage.ANDRO_NAV_ROOT__EVENT_LIBRARY, newEventLibrary, newEventLibrary));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case AndroNavPackage.ANDRO_NAV_ROOT__NAVIGATION:
        return basicSetNavigation(null, msgs);
      case AndroNavPackage.ANDRO_NAV_ROOT__IMAGE_LIBRARY:
        return basicSetImageLibrary(null, msgs);
      case AndroNavPackage.ANDRO_NAV_ROOT__EVENT_LIBRARY:
        return basicSetEventLibrary(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case AndroNavPackage.ANDRO_NAV_ROOT__NAME:
        return getName();
      case AndroNavPackage.ANDRO_NAV_ROOT__NAVIGATION:
        return getNavigation();
      case AndroNavPackage.ANDRO_NAV_ROOT__IMAGE_LIBRARY:
        return getImageLibrary();
      case AndroNavPackage.ANDRO_NAV_ROOT__EVENT_LIBRARY:
        return getEventLibrary();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case AndroNavPackage.ANDRO_NAV_ROOT__NAME:
        setName((String)newValue);
        return;
      case AndroNavPackage.ANDRO_NAV_ROOT__NAVIGATION:
        setNavigation((Navigation)newValue);
        return;
      case AndroNavPackage.ANDRO_NAV_ROOT__IMAGE_LIBRARY:
        setImageLibrary((ImageLibrary)newValue);
        return;
      case AndroNavPackage.ANDRO_NAV_ROOT__EVENT_LIBRARY:
        setEventLibrary((EventLibrary)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case AndroNavPackage.ANDRO_NAV_ROOT__NAME:
        setName(NAME_EDEFAULT);
        return;
      case AndroNavPackage.ANDRO_NAV_ROOT__NAVIGATION:
        setNavigation((Navigation)null);
        return;
      case AndroNavPackage.ANDRO_NAV_ROOT__IMAGE_LIBRARY:
        setImageLibrary((ImageLibrary)null);
        return;
      case AndroNavPackage.ANDRO_NAV_ROOT__EVENT_LIBRARY:
        setEventLibrary((EventLibrary)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case AndroNavPackage.ANDRO_NAV_ROOT__NAME:
        return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
      case AndroNavPackage.ANDRO_NAV_ROOT__NAVIGATION:
        return navigation != null;
      case AndroNavPackage.ANDRO_NAV_ROOT__IMAGE_LIBRARY:
        return imageLibrary != null;
      case AndroNavPackage.ANDRO_NAV_ROOT__EVENT_LIBRARY:
        return eventLibrary != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (name: ");
    result.append(name);
    result.append(')');
    return result.toString();
  }

} //AndroNavRootImpl
